package cn.dujc.superkid.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import java.util.List;

import cn.dujc.core.adapter.BaseAdapter;
import cn.dujc.core.adapter.BaseViewHolder;
import cn.dujc.core.adapter.util.MultiTypeDelegate;
import cn.dujc.superkid.R;
import cn.dujc.superkid.bean.AnswerListResult;
import cn.dujc.superkid.bean.TeacherResult;
import cn.dujc.superkid.bean.VideoListResult;
import cn.dujc.superkid.utils.ImageLoadHelper;

public class TeacherAdapter extends BaseAdapter<Object> {
    public TeacherAdapter(@Nullable List<Object> data) {
        super(data);
        final MultiTypeDelegate<Object> delegate = new MultiTypeDelegate<Object>() {
            @Override
            protected int getItemType(Object o) {
                return o instanceof String ? R.layout.item_teachersfragment_1 : R.layout.item_teachersfragment_2;
            }
        };
        delegate.registerItemType(R.layout.item_teachersfragment_1, R.layout.item_teachersfragment_1)
                .registerItemType(R.layout.item_teachersfragment_2, R.layout.item_teachersfragment_2);
        setMultiTypeDelegate(delegate);
    }

    @Override
    protected void convert(BaseViewHolder helper, Object item) {
        if (item instanceof String) {
            helper.setText(R.id.item_tv_text, (String) item);
        } else if (item instanceof TeacherResult.TeacherListEntity){
            ImageLoadHelper.loadImage((ImageView) helper.getView(R.id.iv_thumb),((TeacherResult.TeacherListEntity) item).getThumb());//暂无头像
            helper.setText(R.id.tv_teacher_name, ((TeacherResult.TeacherListEntity) item).getUser_nicename());
            helper.setText(R.id.Signature, ((TeacherResult.TeacherListEntity) item).getSignature());
        }
    }
}
